package controller;

import org.apache.tomcat.jni.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.file.attribute.UserPrincipalNotFoundException;

@WebServlet(name = "RequestParamsServlet0", urlPatterns = "/RequestParamsServlet0")
public class RequestParamsServlet0 extends HttpServlet {

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String name = request.getParameter("username");
        String password = request.getParameter("password");
        System.out.println("计算机2202班 王丛发 222030503");
        System.out.println("用户名：" + name);
        System.out.println("密  码：" + password);
        String[] hobbys = request.getParameterValues("hobby");
        System.out.println("爱好：");
        for(int i = 0; i < hobbys.length; i ++)
        {
            System.out.println(hobbys[i] + ", ");
        }
    }

    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
